Skip to content

feat(arm): MAVLink v2 .bin telemetry logging to SD card over SPI#4

Merged
Aiden Young (ajyds) merged 3 commits into
mainfrom
feat/mavlink-sd-telemetry
Jun 27, 2026
Merged

feat(arm): MAVLink v2 .bin telemetry logging to SD card over SPI#4
Aiden Young (ajyds) merged 3 commits into
mainfrom
feat/mavlink-sd-telemetry

Conversation

@ehuang2021

Copy link
Copy Markdown
Member

Add a buffered, crash-safe telemetry logger that records the 100 Hz
control loop to an on-board SD card as a stream of CRC-checked MAVLink v2
frames (".bin" flight log), parseable by standard tooling.

  • arm/mavlink_sd_logger.h: header-only MavlinkSdLogger. Canonical
    MCRF4XX CRC, MAVLink v2 framing, block-buffered writes, periodic +
    shutdown flush. SD-over-SPI sink abstracted behind FatFs-shaped
    write/sync callbacks. Per-tick CA_TELEM record; optional stock
    NAMED_VALUE_* for ground stations under MAVLINK_AVAILABLE.
  • arm/drone_main.cpp: log each control tick, periodic fsync, flush and
    close on shutdown with a stats summary.
  • arm/test_mavlink_logger.cpp: 11 unit tests (CRC known-answer, framing,
    field round-trip, buffering, oversize, write-failure recovery, raw
    tee, guards). Wired into arm make test and root make test-arm/CI.
  • mavlink_bridge.h: silence two unused-parameter warnings now that the
    header is pulled into the main build.

ehuang2020 (ehuang2021) and others added 3 commits June 16, 2026 01:04
Add a buffered, crash-safe telemetry logger that records the 100 Hz
control loop to an on-board SD card as a stream of CRC-checked MAVLink v2
frames (".bin" flight log), parseable by standard tooling.

- arm/mavlink_sd_logger.h: header-only MavlinkSdLogger. Canonical
  MCRF4XX CRC, MAVLink v2 framing, block-buffered writes, periodic +
  shutdown flush. SD-over-SPI sink abstracted behind FatFs-shaped
  write/sync callbacks. Per-tick CA_TELEM record; optional stock
  NAMED_VALUE_* for ground stations under MAVLINK_AVAILABLE.
- arm/drone_main.cpp: log each control tick, periodic fsync, flush and
  close on shutdown with a stats summary.
- arm/test_mavlink_logger.cpp: 11 unit tests (CRC known-answer, framing,
  field round-trip, buffering, oversize, write-failure recovery, raw
  tee, guards). Wired into arm `make test` and root `make test-arm`/CI.
- mavlink_bridge.h: silence two unused-parameter warnings now that the
  header is pulled into the main build.
…latency

- Add link-time optimization (-flto) to the ARM release build (RELEASE_FLAGS);
  -O3 was already enabled.
- Add loop_profiler.h: a zero-heap, per-stage latency accumulator (count / mean /
  max us) and a 'make profile' target (-DPROFILE_LOOP). Production builds compile
  the probe macros to no-ops, so the flight binary is unaffected.
- Instrument the control loop in drone_main.cpp across nine stages
  (read_flow, predict, track, evade, write_cmd, console_log, bin_log, flush, TOTAL).
- Add docs/loop-latency.md documenting methodology, measured worst case
  (482 us, 4.8% of the 10 ms budget), and the SD fsync real-hardware caveat.
feat(arm): profile 100 Hz control loop, add LTO, document worst-case latency
@ajyds Aiden Young (ajyds) merged commit 615e352 into main Jun 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants